Skip to content

arch(lint): split layer0.go into focused sibling files - #678

Merged
jeduden merged 5 commits into
mainfrom
claude/youthful-knuth-2x4tpy
Jun 22, 2026
Merged

arch(lint): split layer0.go into focused sibling files#678
jeduden merged 5 commits into
mainfrom
claude/youthful-knuth-2x4tpy

Conversation

@jeduden

@jeduden jeduden commented Jun 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • internal/lint/layer0.go was 1 203 lines, packing seven sub-parsers into one file and making targeted changes risky
  • Extracted three focused siblings within the same lint package (no import changes needed by callers):
    • layer0_html.go: HTML-block detection (types 1–7), openHTMLBlock, htmlBlockCloses, tagName, and related helpers (240 lines)
    • layer0_fence.go: fenceInfo, openingFence, closingFence, advanceFenceState, tryFence (148 lines)
    • layer0_para.go: scanParagraph, markSetextRun, paragraphLeadKind, SourceMayHaveCodeBlock, block-quote helpers (blockDepth, isLazyContinuation, lineHasNonFenceCode, stripQuoteMarker), and list/setext/thematic-break predicates (292 lines)
  • layer0.go now holds exported types, the scanner state machine, and PI/ATX/indented-code sub-parsers — 533 lines, down from 1 203
  • Pure file reorganisation — zero logic changes

Test plan

  • go build ./... passes
  • go test ./... passes (all packages green)
  • go run ./cmd/mdsmith check . passes (508 files, 0 failures)
  • wc -l internal/lint/layer0.go reports 533 (under 600)
  • go tool -modfile=tools/go.mod golangci-lint run — requires Go 1.25.8+; environment has 1.25.0, CI will verify

🤖 Generated with Claude Code

https://claude.ai/code/session_0137dbEGzRTJcTDpCh3QuEFu


Generated by Claude Code

layer0.go at 1 203 lines packed seven sub-parsers into one file,
making targeted changes risky and the file hard to navigate.
Split into three focused siblings within the same package:

- layer0_html.go: HTML-block detection (types 1–7), openHTMLBlock,
  htmlBlockCloses, tagName, and related helpers
- layer0_fence.go: fenceInfo, openingFence, closingFence,
  advanceFenceState, tryFence
- layer0_para.go: scanParagraph, markSetextRun, paragraphLeadKind,
  SourceMayHaveCodeBlock, blockquote helpers (blockDepth,
  isLazyContinuation, lineHasNonFenceCode, stripQuoteMarker),
  and list/setext/thematic-break predicates

layer0.go now holds only the exported types, scanner state machine,
and PI/ATX/indented-code sub-parsers (533 lines, down from 1 203).
Pure file reorganisation — no logic changes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137dbEGzRTJcTDpCh3QuEFu
@codecov

codecov Bot commented Jun 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.62%. Comparing base (4a16047) to head (0bdd9ea).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
Components Coverage Δ
Go 98.61% <100.00%> (+<0.01%) ⬆️
TypeScript 99.54% <ø> (ø)

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

claude added 4 commits June 21, 2026 20:22
gofmt requires no trailing newline after the final closing brace.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137dbEGzRTJcTDpCh3QuEFu
…Block

HTML block type detection (types 2–5) used regexps to match fixed string
prefixes (<!--, <?, <![A-Za-z], <![CDATA[). After the angle-bracket gate
already confirms indent≤3 and line[indent]=='<', these reduce to
bytes.HasPrefix / direct byte comparisons, eliminating 4 package-level
regexp vars and firstNonSpaceIsAngle. Also replaces bytes.Contains with
single-byte needle (htmlClose4) with bytes.IndexByte for the type-4 close
check, removing the htmlClose4 var.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137dbEGzRTJcTDpCh3QuEFu
The two slices were grown from nil via repeated append, triggering
geometric re-allocations for large block quotes. Pre-size to
len(s.lines)-s.i (an upper bound on lines the quote can consume) to
eliminate all intermediate re-allocations, per the project's
pre-size-with-make rule.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137dbEGzRTJcTDpCh3QuEFu
isLazyContinuation checked fences, PIs, and HTML blocks but not ATX
headings. A bare '# heading' line (no > prefix) inside a block quote
was absorbed as a lazy continuation, extending the BlockQuote.End span
past the heading. Per CommonMark §5.1, ATX headings interrupt lazy
continuation.

Also correct the openHTMLBlock comment: 'skip all RE2 executions' was
inaccurate (type-1 lines still run htmlType1Open.Match); now reads
'skip the regexp battery entirely'.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137dbEGzRTJcTDpCh3QuEFu
@jeduden
jeduden marked this pull request as ready for review June 21, 2026 21:03
@jeduden jeduden added queue Add to a PR to enqueue it queue:active Applied automatically when a PR is in an active batch and removed queue Add to a PR to enqueue it labels Jun 22, 2026
@jeduden

jeduden commented Jun 22, 2026

Copy link
Copy Markdown
Owner Author

🟢 Merge Queue — picked up

This PR is in the queue and will be batched with other queue-labelled PRs.

Next: No action needed — you'll get another comment when CI starts on the batch. View merge queue run.

@jeduden

jeduden commented Jun 22, 2026

Copy link
Copy Markdown
Owner Author

🔵 Merge Queue — CI running

Merged into batch branch merge-queue/batch-678-1782128501. View CI run.

Next: No action needed — you'll be notified when CI completes.

@jeduden jeduden removed the queue:active Applied automatically when a PR is in an active batch label Jun 22, 2026
@jeduden
jeduden merged commit c000f05 into main Jun 22, 2026
32 checks passed
@jeduden

jeduden commented Jun 22, 2026

Copy link
Copy Markdown
Owner Author

Merge Queue — merged

This PR landed on main via commit c000f05. CI run that validated the merge.

Next: Done — nothing more to do here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants